<?php

namespace App\Http\Controllers\Activity;

use Validator;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Services\UserGroupService;
use App\Services\PartnerGroupTypeService;
use App\Services\CityService;
use App\Services\UserService;
use Illuminate\Validation\Rule;
use App\BaseDictionary;
use App\UserGroup;
use App\User;
use App\Lib\Auth\UserProfileHelper;

class TeamController extends Controller
{
    private $userGroupService = null;
    private $partnerGroupTypeService = null;
    private $userProfileHelper = null;
    private $userService = null;
    private $cityService = null;

    public function __construct(UserGroupService $userGroupService,
        PartnerGroupTypeService $partnerGroupTypeService,
        UserService $userService,
        CityService $cityService,
        UserProfileHelper $userProfileHelper)
    {
        $this->userGroupService = $userGroupService;
        $this->partnerGroupTypeService = $partnerGroupTypeService;
        $this->userProfileHelper = $userProfileHelper;
        $this->cityService = $cityService;
        $this->userService = $userService;
    }

    //    通过
    public function partnerSuccess()
    {
        return view('backstage.system.group.partner_success', [
            'partnerGroupTypes' => $this->partnerGroupTypeService->getPartnerGroupTypes([
                'groupType' => UserGroup::$GROUP_TYPE_EXTERNAL_ENTERPRISE
            ], false)
        ]);
    }
    //列表
    public function getExternalPartnerSuccess(Request $request)
    {
        return $this->userGroupService
            ->getGroups(array_merge($request->all(), [
                'groupTypes' => [
                    UserGroup::$GROUP_TYPE_EXTERNAL_ENTERPRISE,
                    UserGroup::$GROUP_TYPE_USER
                ],
                'parentId'=>''
            ]));
    }

    //tongguo
    public function partnerDoSuccess(Request $request)
    {
        $input = $request->all();

        $dosuc = UserGroup::findOrFail($input['id']);
        $dosuc->volunteer_group_flag = UserGroup::$GROUP_FLAG_ACTIVE;
        $dosuc->volunteer_num = $input['num'];
        $dosuc->save();

        return response()->json([
            'Success' => true,
            'Message' => '通过成功',
        ]);
    }
}
